# -*- coding:utf-8 -*-
from spider.common.util.HtmlUtil import HtmlUtil
from spider.common.util.SQLUtil import SafeMySQLCRUD

if __name__ == "__main__":
    sqlUtil = SafeMySQLCRUD()
    htmlUtil = HtmlUtil()
    datas=sqlUtil.retrieve_jsons(table='list_tel')

    for data in datas:
        html=data['html']
        eles = htmlUtil.find_elements(html=html, xpath_exp="//div//p")
        update_data={}
        try:
            update_data['wx']=htmlUtil.extarct_view_text(eles[0]).split('：')[1].strip()
            update_data['qq']=htmlUtil.extarct_view_text(eles[1]).split('：')[1].strip()
            update_data['tel']=htmlUtil.extarct_view_text(eles[2]).split('：')[1].strip()
            sqlUtil.update("list_tel", update_data, ("id = %s", (data['id'],)))
        except:
            pass
